package edu.nf.takeoutdemo.web.user;

import edu.nf.takeoutdemo.commons.base.BaseController;
import edu.nf.takeoutdemo.commons.result.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 *
 * @author zjl
 * @date 2025/10/27
 */
@RestController("userShopController")
@RequestMapping("/user/shop")
@Slf4j
@RequiredArgsConstructor
public class ShopController extends BaseController {

    private static final String KEY = "SHOP_STATUS";

    private final RedisTemplate<String,Integer> redisTemplate;

    @GetMapping("/status")
    public Result<Integer> getStatus(){
        Integer status = redisTemplate.opsForValue().get(KEY);
        log.info("获取到店铺的营业状态为：{}",status == 1 ? "营业中":"打烊中");
        return success(status);
    }
}
